﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibBinary.FileData
{
    public class ConditionalData : AbstractFileData
    {
        public bool HasData { get { return Data != null; } }
        public AbstractFileData Data;

        public ConditionalData(AbstractFileData parent)
            : base(parent)
        {
        }

        public override AbstractFileData GetChild(int index)
        {
            if (index != 0)
            {
                throw new ReadingFormatException("Wrong index in ConditionalData.");
            }
            return Data;
        }

        public override string ToString()
        {
            if (!HasData)
            {
                return "<empty>";
            }
            return Data.ToString();
        }
    }
}
